package com.study.post.filter;

import com.study.post.filter.filter.PermissonFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;

@SpringBootApplication
public class PostFilterApplication {

    public static void main(String[] args) {
        SpringApplication.run(PostFilterApplication.class, args);
    }

    @Bean
    public FilterRegistrationBean<PermissonFilter> permissonFilterFilterRegistrationBean(PermissonFilter permissonFilter){
        FilterRegistrationBean<PermissonFilter> registrationBean = new FilterRegistrationBean<>(permissonFilter);
        registrationBean.setUrlPatterns(Arrays.asList("/users"));
        registrationBean.setOrder(0);
        return registrationBean;
    }

    @Bean
    public PermissonFilter permissonFilter(){
        return new PermissonFilter();
    }
}
